<template>
  <view class="user-info-card">
    <image class="avatar" :src="user.avatar" mode="aspectFill" @click="changeProfile"/>
    <view class="info">
      <text class="nickname" @click="changeInfo('name')">{{ user.nickname }}</text>
      <text class="bio" @click="changeInfo('desc')">{{ user.bio }}</text>
    </view>
	<view></view>
	<view class="loginButton" @click="toLogin">
		<text v-if="user.isLogin">退出登录</text>
		<text v-if="!user.isLogin">登录</text>
	</view>
  </view>
</template>

<script setup>
defineProps({
  user: {
    type: Object,
    required: true,
  },
  changeProfile:{
	  type:Function
  },
  changeInfo:{
	  type:Function
  }
});


function toLogin(){
	uni.navigateTo({
		url:'/pages/login/login'
	})
}
</script>

<style lang="scss" scoped>
.user-info-card {
  display: flex;
  align-items: center;
  padding: 20px;
  background-color: #fff;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);

  .avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    margin-right: 15px;
  }

  .info {
    display: flex;
    flex-direction: column;

    .nickname {
      font-size: 18px;
      font-weight: bold;
      margin-bottom: 5px;
    }

    .bio {
      font-size: 14px;
      color: #666;
	  
    }
  }
  
  .loginButton{
	  float: right;
	  font-size: 28rpx;
	  width: 150rpx;
	  position: relative;
	  left: 40rpx;
	  bottom: 80rpx;
  }
}
</style>